package com.tedu.pojo.controller;
//用户模块的控制器,模拟用户登录与注册

import com.tedu.pojo.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller  //声明为处理器,用于处理用户请求
public class UserController {

//    UserServices userServices = new UserServicesImpl();

    @Autowired
    UserServices userServices;

    @RequestMapping("/login")
    public String login(String username, String password, Model model){
        System.out.println(username+",你正在进行登录操作");
        if (username != null && username.equals("admin") && password != null && password.equals("admin")){
            //登录成功
            model.addAttribute("msg","恭喜,"+username+"登录成功!");
        }else{
            //登录失败
            model.addAttribute("msg","很遗憾,"+username+"登录失败!");
        }
        return "main";
    }

    @RequestMapping("/toregister")
    public String toRegister(String username, String password){

        return "register";

    }

    @RequestMapping("/register")
    public String register(String username, String password){
        return "redirect:/index.jsp";

    }

}
